<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%
			String basepath = request.getContextPath();
		%>
		<script type="text/javascript">
		jQuery(document).ready(
			function(){
				//供应商类型
				initselect("suptype",'${currentInfo.suptype}');
				//企业性质
				initselect("entproperty",'${currentInfo.entproperty}');
				//初始化两个字段：所属行业，经济类型
				initmodel("industryname,ectypename","${currentInfo.industry}"+","+"${currentInfo.ectype}");
			}
		)
		
	//这里进行提交
	function commit() {
		//首先进行页面的JS验证
		var valid = CheckSupInfo();
		if(valid ==false){
			return false;
		}
		document.forms[0].action = "<%=basepath %>/register/invitecommitsupinfo";
		document.forms[0].submit();
		
	}
	
	function save(){
		var valid = CheckSupInfo();
		if(valid ==false){
			return false;
		}
		document.forms[0].action = "<%=basepath %>/register/invitesavesupinfo";
		document.forms[0].submit();
	}
	//初始化下拉列表
	function initList(id,code){
		var url = "iframe:<%=basepath%>/register/initlist?id="+id+"&code="+code;
		dialog("", url,"500", "400", "","");
	}
	
	//初始化参考数据的名称
	function initmodel(name,pk){
		jQuery.ajax(
				{
				type: "GET", 
	            async:false,
	            url:"<%=basepath%>/register/initmodel?pk="+pk, 
	            dataType:"text", 
	            success:function(result){   
	                if(result !='')
	                {
	                	var items = result.split("|");
	                	var nameitem = name.split(",");
	                	for(var i=0;i<nameitem.length;i++)
	                	{
	                		if(i<items.length)
	                		{
	                			document.getElementById(nameitem[i]).value = items[i];
	                		}
	                	}
	                }
	            } 
	        }
		)
	}
	
	//初始化产品和资质分类弹出层
	function initItem(type,id,pk_org,pk_group)
	{
		var url = "url:post?<%=basepath%>/register/inititem?type="+type+"&id="+id+"&pk_org="+pk_org+"&pk_group="+pk_group;
		//alert(url);
		dialog("", url,"500", "400", "","");
	}
	
	function deleterow(index,id)
	{
		var table = document.getElementById(id);
		table.deleteRow(index);
		
		//还得重新刷新序号
		var rows = table.rows;
		var length = rows.length;
		if(rows.length>2)
		{
			for(var i=1;i<rows.length-1;i++)
			{
				var row = rows[i];
				var cell = row.cells[0];
				cell.innerHTML = i;
				cell =  row.cells[2];
				cell.innerHTML = "<a href=\"javascript:deleterow("+i+",'"+id+"');\">删除</a>";
			}
		}
	}
</script>

	</head>

	<body class="fullbody">
		<div id="content" class="content">
			<div class="">
				<table cellpadding="0" cellspacing="0" border="0" width="980" class="datatable">
					<tr>
						<td class="leftmargin">
						</td>
						<td valign="top" align="left">
							<form method="post">
								<table cellpadding="0" cellspacing="0" border="0" width="920">
									<tr class="title">
										<td colspan="4">
											基本信息
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											供应商名称：
										</td>
										<td class="w5">
											<input type="hidden" name="pk_supinfocheck_h" value="${currentInfo.pk_supinfocheck_h}"/>
											<input type="text" name="supname" class="textstyle"
												value="${currentInfo.supname}" />
											<span class="needfill">*</span>
										</td>
										<td class="w1">
											供应商简称：
										</td>
										<td class="w5">
											<input type="text" name="supsimname"
												value="${currentInfo.supsimname}" class="textstyle" />
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											英文名称：
										</td>
										<td class="w5">
											<input type="text" name="supenname" class="textstyle"
												value="${currentInfo.supenname}" />
										</td>
										<td class="w1">
											所属行业：
										</td>
										<td class="w5">
											<input type="text" name="industryname" id="industryname" class="textstyle"
											 onclick="initList('industry','SYS005')" readOnly/>
												<input type="hidden" name="industry" id="industry" class="textstyle"
												value="${currentInfo.industry}" readOnly/>
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											供应商类型：
										</td>
										<td class="w5">
											<select name="suptype" id="suptype" class="textstyle">
												<option value="0">
													外部单位
												</option>
												<option value="1">
													内部单位
												</option>
											</select>
											<span class="needfill">*</span>
										</td>

										<td class="w1">
											企业性质：
										</td>
										<td class="w5">
											<select name="entproperty" id="entproperty" class="textstyle">
												<option value="1">
													上市公司
												</option>
												<option value="2">
													非上市公司
												</option>

											</select>
											<span class="needfill">*</span>
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											法人：
										</td>
										<td class="w5">
											<input type="text" name="legalbody"
												value="${currentInfo.legalbody}" class="textstyle" />
										</td>
										<td class="w1">
											注册资本：
										</td>
										<td class="w5">
											<input type="text" name="regfound"
												value="${currentInfo.regfound}" class="textstyle" />
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											经济类型：
										</td>
										<td class="w5">
											<input type="text" name="ectypename" id="ectypename"
												 class="textstyle" onclick="initList('ectype','SYS004_0xx')" readOnly/> 
											<input type="hidden" name="ectype" id="ectype"
												value="${currentInfo.ectype}" class="textstyle"  readOnly/>
										</td>
										<td class="w1">
											成立日期：
										</td>
										<td class="w5">
											<input type="text" style="width: 200" name="builddate"
												value="${currentInfo.builddate}" id="builddate"
												onclick="WdatePicker();" readOnly class="textstyle" />
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											纳税人登记号：
										</td>
										<td class="w5">
											<input type="text" name="taxpayerid"
												value="${currentInfo.taxpayerid}" class="textstyle" />
											<span class="needfill">*</span>
										</td>
										<td class="w1">
											经营场所面积：
										</td>
										<td class="w5">
											<input type="text" name="bizarea"
												value="${currentInfo.bizarea}" class="textstyle" />
										</td>
									</tr>
									<tr class="inputrow">
										<td class="w1">
											营业执照号：
										</td>
										<td class="w5">
											<input type="text" name="salelicenceno"
												value="${currentInfo.salelicenceno}" class="textstyle" />
											<span class="needfill">*</span>
										</td>
										<td class="w1">
											工人人数：
										</td>
										<td class="w5">
											<input type="text" name="employeenum"
												value="${currentInfo.employeenum}" class="textstyle" />
										</td>
									</tr>
									<tr class="title">
                                <td colspan="4">
                                   	 产品分类<span class="needfill">*</span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" align="center"><br />
                                    <table id="producttable" cellpadding="0" cellspacing="0" border="1" width="740" class="datalist">
                                        <tr class="datahead">
                                            <th>序号
                                            </th>
                                            <th>产品分类名称
                                            </th>
                                            <th>删除
                                            </th>
                                        </tr>
                                        <c:if test="${currentInfo.infoProVOs !=null}">
                                        <c:forEach items="${currentInfo.infoProVOs}" var="product" varStatus="index">
                                        <tr class="datarow">
                                            <td>${index.count}
                                            </td>
                                            <td><input name="proname" type="text" class="textinput" readOnly/><input name="propk" type="hidden" class="textinput" value="${product.pk_marbasclass}"/>
                                            </td>
                                            <td><a href="javascript:deleterow('${index.count}','producttable');">删除</a>
                                            </td>
                                        </tr>
                                        </c:forEach>
                                        </c:if>
                                         <tr class="datarow">
                                            <td colspan="4" align="left">
                                                &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:initItem('1','producttable','${currentInfo.pk_org}','${currentInfo.pk_group}')">增加一个新的产品分类</a>
                                            </td>
                                       	 </tr>
                                    </table>
                               </td>
                            </tr>
                            <tr class="title">
                                <td colspan="4">
                                   	 资质分类<span class="needfill">*</span>
                                </td>
                            </tr>
                            <tr>
                            	<td colspan="4" align="center"><br />
                                    <table id="qualtitytable" cellpadding="0" cellspacing="0" border="0" width="740" class="datalist">
                                        <tr class="datahead">
                                            <th>序号
                                            </th>
                                            <th>资质分类名称
                                            </th>
                                            <th>删除
                                            </th>
                                        </tr>
                                        <c:if test="${currentInfo.infoQaVos !=null}">
                                        <c:forEach items="${currentInfo.infoQaVos}" var="qa" varStatus="index">
                                        <tr class="datarow">
                                            <td>${index.count}
                                            </td>
                                            <td><input name="qaname" type="text" class="textinput" readOnly/><input name="qapk" type="hidden" class="textinput" value="${qa.pk_qualifitype}" readOnly/>
                                            </td>
                                            <td><a href="javascript:deleterow('${index.count}','qualtitytable');">删除</a>
                                            </td>
                                        </tr>
                                        </c:forEach>
                                        </c:if>
                                        <tr class="datarow">
                                            <td colspan="4" align="left">
                                                &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:initItem('2','qualtitytable','${currentInfo.pk_org}','${currentInfo.pk_group}')">增加一个新的资质分类</a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
									<tr>
										<td colspan="4">
											<div id="message" class="msgcolor">
												<c:out value="${ERROR_MESSAGE}"></c:out>
											</div>
										</td>
									</tr>
									<tr>
										<td colspan="4">
											&nbsp;
										</td>
									</tr>
									<tr class="buttonrow">
										<td align="right" colspan="4">
											<input type="button" value="暂存" onclick="save();"
												class="submitbutton" />
											&nbsp;&nbsp;
											<input type="button" value="提交审核" onclick="commit();"
												class="submitbutton" />
										</td>
									</tr>
								</table>
							</form>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</body>